package cn.itcast.javabase;

/**
 * @title: A02
 * @Author Zhou
 * @Date: 2022/1/18 14:12
 * @Version 1.0
 */
public class A02 {
    public static void main(String[] args) {
        FindSame findSame = new FindSame();
        String[] arr = {"mike", "tom", "jessica"};
        int mike = findSame.find("mike", arr);
        System.out.println("mike = " + mike);
    }
}

class FindSame {
    public int find(String s, String[] arr) {
        if (arr != null && arr.length != 0) {
            for (int i = 0; i < arr.length; i++) {
                if (s.equals(arr[i])) {
                    return i;
                }
            }
        }
        return -1;
    }
}
